home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.11 Nov 90 / NeuralNet Estimator⁄EDIT / Neural Network Main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-03  |  2.5 KB  |  98 lines  |  [TEXT/KAHL]

  1.  
  2. #include "Neural Network.h"
  3. #include <math.h>
  4.  
  5. /*---- Debuging prototypes and structs ----*/
  6. Stestnet(NeuralNet *);
  7. FILE * Jac;
  8. /*-----------------------------------------*/
  9.  
  10. /*** Global structures *****************/
  11. NeuralNet * theNet;        /* pointer to a NeuralNet structure */
  12. NeuralNet Nets[ActiveNets];/* array of available model structures */
  13.  
  14. DTypeVector    yData;         /* output values of neural network, is (#Obs)x1 */
  15. DTypeMatrix    XData;        /* input values of neural network, is (#Obs) x (#Input Neurons) */
  16. DTypeMatrix Jac_T;        /* transpose of Jacobian matrix, is (#Parms)x(#Obs) 
  17.                             Parameters are arranged such that the (1,1) element of W[0]
  18.                             is in the first row, and the (N,N) element of W[OutLayer] is
  19.                             in the last row */
  20. DTypeVector Pi, Diag;    /* vectors for pi and diagonal values from QR decomposition, 
  21.                             are (#Parms)x1 */
  22. DTypeVector Resid;        /* residuals at current value, used with Jacobian to calc next 
  23.                             step, is (#Obs)x1 like yData */
  24. DTypeVector gradSS;        /* gradient of the SS function, is (#Parms)x1, used in stop criteria */
  25. DTypeMatrix Phi, T2;    /* temporary storage for matrix products used in calculation of Jacobian */
  26. DTypeVector dSquash[MaxLay];    /* vector of derivative of the squashing function */
  27. DTypeVector Alpha[MaxLay];    /* vector of values after applying squashing function */
  28.  
  29. /***************************************************************************/
  30. main()
  31. {
  32. theNet = &Nets[0];
  33. printf("this is test\n");
  34. if((Jac = fopen("Testdata:Jacobian","w"))==NULL)
  35. {    printf("Can't open file");
  36.     ExitToShell();
  37. }
  38.  
  39. SetupNetDefaults();
  40. SetTestNet(theNet);
  41. AllotInitNewNetWeights();
  42. testData(theNet);
  43.  
  44. Estimate();
  45. theNet->method = HookeJeeves;
  46. Estimate();
  47.  
  48. fclose(Jac);
  49.  
  50. }
  51.  
  52. /***************************************************************************/
  53.  
  54.  
  55. Estimate()
  56. {
  57.     int termcode;    
  58.  
  59.     HLock(yData.cells);
  60.     HLock(XData.cells);
  61.     
  62.     switch(theNet->method)
  63.     {    case BackProp:
  64.         {    break;
  65.         }
  66.         case SimAnn:
  67.         {    break;
  68.         }
  69.         case HookeJeeves:
  70.         {    AllotSearchWorkSpace();
  71.             LockSearchWorkSpace();
  72.             termcode = do_HookeJeeves();
  73.             UnlockSearchWorkSpace();
  74.             break;
  75.         }
  76.         case GaussNew:
  77.         {    AllotGradientWorkSpace();
  78.             LockGradientWorkSpace();
  79.             termcode = do_GaussNewton();
  80.             UnlockGradientWorkSpace();
  81.             break;    
  82.         }
  83.         case qGaussNew:
  84.         {    AllotGradientWorkSpace();
  85.             LockGradientWorkSpace();
  86.             termcode = do_quasiGaussNewton();
  87.             UnlockGradientWorkSpace();
  88.             break;    
  89.         }
  90.         default:
  91.             NotYetAvail();
  92.     }
  93.  
  94.     HUnlock(yData.cells);
  95.     HUnlock(XData.cells);
  96.     
  97.     return(termcode);
  98. }